class OceanBaseBackupServiceEx(OceanBaseBackupService):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.backup_mode = "FULL"  # FULL/INCREMENTAL/LOG
        
    def check_backup_job_type(self):
        """动态调整备份类型"""
        # 如果存在全量备份且未超过保留周期，则转为增量
        if self._has_valid_full_backup():
            self.backup_mode = "INCREMENTAL"
            log.info("Switch to incremental backup mode")
            
    def _has_valid_full_backup(self):
        """检查有效全量备份"""
        # 实现备份集有效期检查逻辑
        return True
        
    def exec_data_backup_sub_job(self):
        """执行数据备份"""
        if self.backup_mode == "FULL":
            self._full_backup()
        elif self.backup_mode == "INCREMENTAL":
            self._incremental_backup()
            
    def _full_backup(self):
        """全量备份实现"""
        cmd = f"ALTER SYSTEM BACKUP DATABASE {self.db_name} TO '{self.backup_path}'"
        self._execute_ob_cmd(cmd)
        
    def _incremental_backup(self):
        """增量备份实现"""
        cmd = f"ALTER SYSTEM BACKUP INCREMENTAL DATABASE {self.db_name} TO '{self.backup_path}'"
        self._execute_ob_cmd(cmd)
        
    def exec_log_copy_sub_job(self):
        """日志备份处理"""
        self._archive_log()
        self._copy_log_files()
        
    def _archive_log(self):
        """开启日志归档"""
        cmd = f"ALTER SYSTEM ARCHIVELOG"
        self._execute_ob_cmd(cmd)